﻿@model IEnumerable<WebVideo.EntityNew>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<script src="../../../../Content/cssAdmin/js/plugins/jquery-1.7.min.js"></script>
<script src="../../../../Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
@*<script src="../../../../Content/cssAdmin/js/plugins/jquery.validate.min.js"></script>
<script src="../../../../Content/cssAdmin/js/plugins/jquery.validate.unobtrusive.min.js"></script>*@

@*<script src="../../../../Content/cssAdmin/js/custom/tables.js"></script>*@
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('.stdtable a.delete').click(function () {
            var c = confirm('Continue delete?');
            var id = $(this).closest('tr').find('td:eq(0)').text();

            if (c) jQuery(this).parents('tr').fadeOut(function () {

                var getURL = '@Url.Action("Delete", "News")';
	        alert(id);
	        $.get(getURL, { "id": id }, function (data) {
	            if (data == "error") //error
	            {
	                $('#nofError').show();
	                $('#nofSuccess').hide();
	                $('#msgNofError').text("Cannot Delete Record");
	            }
	            else {
	                jQuery(this).remove();
	                $('#nofError').hide();
	                $('#nofSuccess').show();
	                $('#msgNofSuccess').text("Delete Record Ok");
	            }
	        });
	    });
            return false;
        });
    });
 
    //function RutGon() {
    //    alert("bc");
    //    var str = $('#Des').text();
    //    alert(str);

    //    $('#Des').html(str.substring(0, 10) + "...");
    //}
</script>
<div class="maincontentinner">
    <ul class="maintabmenu">
        <li class="current"><a href="@Url.Action("Index", "News")" >Index</a></li>
        <li class="current"><a href="@Url.Action("Insert", "News")" >Insert</a></li>
    </ul>
    <!--maintabmenu-->
    <div class="notification msgsuccess" style="display: none" id="nofSuccess">
        <a class="close"></a>
        <p id="msgNofSuccess">This is a success message.</p>
    </div>
    <!-- notification msgsuccess -->
    <div class="notification msgerror" style="display: none" id="nofError">
        <a class="close"></a>
        <p id="msgNofError">This is an error message.</p>
    </div>
    <!-- notification msgerror -->
    <div class="contenttitle radiusbottom0">
        <h2 class="table"><span>List News</span></h2>
    </div>
    <!--contenttitle-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
        <colgroup>
            <col class="con0" />
            <col class="con1" />
            <col class="con0" />
            <col class="con1" />
        </colgroup>
        <thead>
            <tr>
                <th class="head0">ID</th>
                <th class="head1">Tiêu đề</th>
                <th class="head0">Nội dung</th>
                <th class="head1">Hình ảnh </th>
                <th class="head0">Meta Description</th>
                <th class="head1">Meta KeyWord</th>
                <th class="head0">Ngày tạo</th>
                <th class="head1">Loại tinh tức</th>
                <th class="head0"></th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th class="head0">ID</th>
                <th class="head1">Tiêu đề</th>
                <th class="head0">Nội dung</th>
                <th class="head1">Hình ảnh </th>
                <th class="head0">Meta Description</th>
                <th class="head1">Meta KeyWord</th>
                <th class="head0">Ngày tạo</th>
                <th class="head1">Loại tinh tức</th>
                <th class="head0"></th>
            </tr>
        </tfoot>
        <tbody>
            @{
               
                foreach (var item in Model)
                {
                 
                <tr class="gradeX">
                    <td>
                       @Html.DisplayFor(modelitem => item.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.Title)
                    </td>
                    <td>
                        <div>
                         
                              @Html.Raw(item.Des)
                            
                         </div>
                    </td>
                    <td>
                        @{
                    var imageFile = "~/Content/Images/TinTuc/";
                    if (item.Image != null)
                    {
                        imageFile += @item.Image;
                    }
                    else
                    {
                        imageFile += "no-photo.jpg";
                    }
                        }
                        <img src= "@Url.Content(imageFile)" style="width:100px; height:100px" alt="" />
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.MetaDescription)
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.MetaKeyWord)
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.Date)
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.EntityTypeNew.Name)
                    </td>
                    <td class ="eddelete">
                       
                        @Html.ActionLink(" ", "Edit", new { IdNews = @item.Id }, new { @class = "edit",title="Edit"  })
                 
                        <a href="#" class="delete" title="Delete" , onclick='DeleteRecord("@item.Id ")' ></a>
                    </td>
                </tr> 
                }                      
            }
        </tbody>
    </table>
</div>
<!--maincontentinner-->
<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/custom/tables.js")" ></script>
<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery.dataTables.min.js")" ></script>